console.log(location.href)
const p = location.search
$(".f2>.container>.body>div").remove() //移除页面元素
let url = "/index/course_input" + p
$.get(url, data => {
	console.log(data)

	let html = data.map(value => {
		const {
			course_brief: brief,
			course_title: title,
			course_hourse: h,
			course_studyNumber: n,
			course_image: img,
			course_id: id,
			course_teach: ch,
			course_fees: f,
		} = value;
		console.log(id)
		if (id < 17) {
			return ` <div>
					<a href="course_detail.html?lid=${id}">
						<img src="${img}">
						<div id="">
							<p>${title}</p>
							<p><span>学习人数：${n}</span><span>进阶:${h}h</span></p>
						</div>
					</a>
				</div>
			 `
		} else {
			return `
						<a href="shizhan_course_detail.html?lid=${id}">
								<div>
									<div>
										<img src="${img}" alt="">
											<p class="p1">${title}</p>
											<p class="p2">
												<span>${ch}</span>
												<span>高级工程师</span>
											</p>
											<div class="body_zhe">
												<div>折</div>
												<span>￥${f}元</span>
											</div>
											<div class="body_mai" >
												<span><img src="./img/学生档案.png">${n}人加入学习</span>
												<span>加入购物车</span>
											</div>
										</div>
									</div>
							</a>
					`
		}
	})

	$('.f2>.container>.body').append(html)
})




$('#input').keydown(function(event) {
	// let val=$('#input').val();
	// console.log(val)
	if (event.keyCode == 13) {
		$(".f2>.container>.body>div").remove() //移除页面元素
		// $(window).attr('location','/input.html');
		let keyword = $(this).val()
		let url = `/index/course_input?keyword=${keyword}`
		$.get(url, data => {
			console.log(data)

			let html = data.map(value => {
				const {
					course_brief: brief,
					course_title: title,
					course_hourse: h,
					course_studyNumber: n,
					course_image: img,
					course_id: id,
					course_teach:ch,
					course_fees:f,
				} = value;
				console.log(id)
				if (id < 17) {
					return ` <div>
					<a href="course_detail.html?lid=${id}">
						<img src="${img}">
						<div id="">
							<p>${title}</p>
							<p><span>学习人数：${n}</span><span>进阶:${h}h</span></p>
						</div>
					</a>
				</div>
			 `}
				 else {
					return `
						<a href="shizhan_course_detail.html?lid=${id}">
								<div>
									<div>
										<img src="${img}" alt="">
											<p class="p1">${title}</p>
											<p class="p2">
												<span>${ch}</span>
												<span>高级工程师</span>
											</p>
											<div class="body_zhe">
												<div>折</div>
												<span>￥${f}元</span>
											</div>
											<div class="body_mai" >
												<span><img src="./img/学生档案.png">${n}人加入学习</span>
												<span>加入购物车</span>
											</div>
										</div>
									</div>
							</a>
					`
				}
			})

			$('.f2>.container>.body').append(html)
		})
	}
})
